package com.yty.demo._6_collection;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: yangtaoyao
 * @time: 2020/1/13 13:42
 * @description: List
 */
public class ListTest {
    public static void main(String[] args) {
        List<Integer> list=new ArrayList<>();
        list.add(16);
        list.add(30);
        list.add(10);
        System.out.println(list);
        System.out.println(list.get(0));
        list.add(0,10);

        System.out.println(list);
        List<Integer> l=new ArrayList<>();
        l.add(22);
        list.addAll(4,l);
        System.out.println(list);

        System.out.println(list.subList(0,2));//fromIndex, toIndex
        System.out.println(list.indexOf(10));//0
        System.out.println(list.lastIndexOf(10));//3
        list.remove(1);
        list.remove(Integer.valueOf(10));//[30, 10, 22]
        list.set(2,3);//(index,value) index 不能越界
        System.out.println(list);
    }
}
